package it.stasbranger.myproject.domain;

import java.io.Serializable;

import java.lang.StringBuilder;

import java.util.Date;
import java.util.Set;

import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;

import org.codehaus.jackson.annotate.JsonIgnore;

import javax.xml.bind.annotation.*;

import javax.persistence.*;

/**
 */
@IdClass(it.stasbranger.myproject.domain.SuppliersHasRequestsPK.class)
@Entity
@NamedQueries({
		@NamedQuery(name = "findAllSuppliersHasRequestss", query = "select mySuppliersHasRequests from SuppliersHasRequests mySuppliersHasRequests"),
		@NamedQuery(name = "findSuppliersHasRequestsByPrice", query = "select mySuppliersHasRequests from SuppliersHasRequests mySuppliersHasRequests where mySuppliersHasRequests.price = ?1"),
		@NamedQuery(name = "findSuppliersHasRequestsByPrimaryKey", query = "select mySuppliersHasRequests from SuppliersHasRequests mySuppliersHasRequests where mySuppliersHasRequests.suppliersIdsuppliers = ?1 and mySuppliersHasRequests.requestsIdrequests = ?2"),
		@NamedQuery(name = "findSuppliersHasRequestsByRequestsIdrequests", query = "select mySuppliersHasRequests from SuppliersHasRequests mySuppliersHasRequests where mySuppliersHasRequests.requestsIdrequests = ?1"),
		@NamedQuery(name = "findSuppliersHasRequestsBySenddate", query = "select mySuppliersHasRequests from SuppliersHasRequests mySuppliersHasRequests where mySuppliersHasRequests.senddate = ?1"),
		@NamedQuery(name = "findSuppliersHasRequestsBySuppliersIdsuppliers", query = "select mySuppliersHasRequests from SuppliersHasRequests mySuppliersHasRequests where mySuppliersHasRequests.suppliersIdsuppliers = ?1") })
@Table(catalog = "mydb", name = "suppliers_has_requests")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(namespace = "MyProject/it/stasbranger/myproject/domain", name = "SuppliersHasRequests")
public class SuppliersHasRequests implements Serializable {
	private static final long serialVersionUID = 1L;

	/**
	 */

	@Column(name = "suppliers_idsuppliers", nullable = false)
	@Basic(fetch = FetchType.EAGER)
	@Id
	@XmlElement
	Integer suppliersIdsuppliers;
	/**
	 */

	@Column(name = "requests_idrequests", nullable = false)
	@Basic(fetch = FetchType.EAGER)
	@Id
	@XmlElement
	Integer requestsIdrequests;
	/**
	 */
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "senddate")
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	Date senddate;
	/**
	 */

	@Column(name = "price")
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	Integer price;

	/**
	 */
	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumns({ @JoinColumn(name = "suppliers_idsuppliers", referencedColumnName = "idsuppliers", nullable = false, insertable = false, updatable = false) })
	@XmlTransient
	Suppliers suppliers;
	/**
	 */
	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumns({ @JoinColumn(name = "requests_idrequests", referencedColumnName = "idrequests", nullable = false, insertable = false, updatable = false) })
	@XmlTransient
	Requests requests;

	/**
	 */
	public void setSuppliersIdsuppliers(Integer suppliersIdsuppliers) {
		this.suppliersIdsuppliers = suppliersIdsuppliers;
	}

	/**
	 */
	public Integer getSuppliersIdsuppliers() {
		return this.suppliersIdsuppliers;
	}

	/**
	 */
	public void setRequestsIdrequests(Integer requestsIdrequests) {
		this.requestsIdrequests = requestsIdrequests;
	}

	/**
	 */
	public Integer getRequestsIdrequests() {
		return this.requestsIdrequests;
	}

	/**
	 */
	public void setSenddate(Date senddate) {
		this.senddate = senddate;
	}

	/**
	 */
	public Date getSenddate() {
		return this.senddate;
	}

	/**
	 */
	public void setPrice(Integer price) {
		this.price = price;
	}

	/**
	 */
	public Integer getPrice() {
		return this.price;
	}

	/**
	 */
	public void setSuppliers(Suppliers suppliers) {
		this.suppliers = suppliers;
	}

	/**
	 */
	@JsonIgnore
	public Suppliers getSuppliers() {
		return suppliers;
	}

	/**
	 */
	public void setRequests(Requests requests) {
		this.requests = requests;
	}

	/**
	 */
	@JsonIgnore
	public Requests getRequests() {
		return requests;
	}

	/**
	 */
	public SuppliersHasRequests() {
	}

	/**
	 * Copies the contents of the specified bean into this bean.
	 *
	 */
	public void copy(SuppliersHasRequests that) {
		setSuppliersIdsuppliers(that.getSuppliersIdsuppliers());
		setRequestsIdrequests(that.getRequestsIdrequests());
		setSenddate(that.getSenddate());
		setPrice(that.getPrice());
		setSuppliers(that.getSuppliers());
		setRequests(that.getRequests());
	}

	/**
	 * Returns a textual representation of a bean.
	 *
	 */
	public String toString() {

		StringBuilder buffer = new StringBuilder();

		buffer.append("suppliersIdsuppliers=[").append(suppliersIdsuppliers).append("] ");
		buffer.append("requestsIdrequests=[").append(requestsIdrequests).append("] ");
		buffer.append("senddate=[").append(senddate).append("] ");
		buffer.append("price=[").append(price).append("] ");

		return buffer.toString();
	}

	/**
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = (int) (prime * result + ((suppliersIdsuppliers == null) ? 0 : suppliersIdsuppliers.hashCode()));
		result = (int) (prime * result + ((requestsIdrequests == null) ? 0 : requestsIdrequests.hashCode()));
		return result;
	}

	/**
	 */
	public boolean equals(Object obj) {
		if (obj == this)
			return true;
		if (!(obj instanceof SuppliersHasRequests))
			return false;
		SuppliersHasRequests equalCheck = (SuppliersHasRequests) obj;
		if ((suppliersIdsuppliers == null && equalCheck.suppliersIdsuppliers != null) || (suppliersIdsuppliers != null && equalCheck.suppliersIdsuppliers == null))
			return false;
		if (suppliersIdsuppliers != null && !suppliersIdsuppliers.equals(equalCheck.suppliersIdsuppliers))
			return false;
		if ((requestsIdrequests == null && equalCheck.requestsIdrequests != null) || (requestsIdrequests != null && equalCheck.requestsIdrequests == null))
			return false;
		if (requestsIdrequests != null && !requestsIdrequests.equals(equalCheck.requestsIdrequests))
			return false;
		return true;
	}
}
